// 简化版打卡系统常量定义
// 作者：guo.wenliang
// 创建时间：2025/8/13
// 简化说明：移除子打卡概念，只保留主打卡活动

// 打卡状态（数字类型）
export const CHECKIN_STATUS = {
  PENDING: 0,        // 待开始
  ACTIVE: 1,         // 进行中
  COMPLETED: 2,      // 已完成
  PAUSED: 3,         // 暂停
};

// 打卡记录状态
export const RECORD_STATUS = {
  COMPLETED: 'completed',     // 已完成
  IN_PROGRESS: 'in_progress', // 进行中
};

export const CHECKIN_STATUS_OPTIONS = [
  { value: CHECKIN_STATUS.PENDING, label: '待开始' },
  { value: CHECKIN_STATUS.ACTIVE, label: '进行中' },
  { value: CHECKIN_STATUS.COMPLETED, label: '已完成' },
  { value: CHECKIN_STATUS.PAUSED, label: '暂停' },
];

export const RECORD_STATUS_OPTIONS = [
  { value: RECORD_STATUS.COMPLETED, label: '已完成' },
  { value: RECORD_STATUS.IN_PROGRESS, label: '进行中' },
];

// 打卡频率选项
export const CHECKIN_FREQUENCY_OPTIONS = [
  { value: 1, label: '每天' },
  { value: 2, label: '每2天' },
  { value: 3, label: '每3天' },
  { value: 4, label: '每4天' },
  { value: 5, label: '每5天' },
  { value: 6, label: '每6天' },
  { value: 7, label: '每周' },
  { value: 10, label: '每10天' },
  { value: 15, label: '每15天' },
];

// 获取状态对应的颜色
export const getStatusColor = (status) => {
  switch (status) {
    case CHECKIN_STATUS.ACTIVE:
      return 'green';
    case CHECKIN_STATUS.PENDING:
      return 'orange';
    case CHECKIN_STATUS.COMPLETED:
      return 'blue';
    case CHECKIN_STATUS.PAUSED:
      return 'red';
    default:
      return 'default';
  }
};


// 获取状态标签
export const getStatusLabel = (status) => {
  const statusConfig = CHECKIN_STATUS_OPTIONS.find(s => s.value === status);
  return statusConfig?.label || '未知状态';
};

export const getRecordStatusLabel = (status) => {
  const statusConfig = RECORD_STATUS_OPTIONS.find(s => s.value === status);
  return statusConfig?.label || '未知状态';
};

// 默认值
export const DEFAULTS = {
  PAGE_SIZE: 20,
  TARGET_DAYS: 30,
  DURATION: 30,
  MAX_PARTICIPANTS: 100,
  MAX_TITLE_LENGTH: 255,
  MAX_DESCRIPTION_LENGTH: 1000,
  MAX_TAGS_COUNT: 5,
};

// 权限常量
export const PERMISSIONS = {
  CREATE_ACTIVITY: 'create_activity',
  EDIT_ACTIVITY: 'edit_activity',
  DELETE_ACTIVITY: 'delete_activity',
  MANAGE_PARTICIPANTS: 'manage_participants',
  VIEW_ALL_RECORDS: 'view_all_records',
  EXPORT_DATA: 'export_data',
};

// 表单验证规则
export const VALIDATION_RULES = {
  TITLE: [
    { required: true, message: '请输入活动名称' },
    { max: DEFAULTS.MAX_TITLE_LENGTH, message: `活动名称不能超过${DEFAULTS.MAX_TITLE_LENGTH}个字符` }
  ],
  DESCRIPTION: [
    { required: true, message: '请输入活动描述' },
    { max: DEFAULTS.MAX_DESCRIPTION_LENGTH, message: `活动描述不能超过${DEFAULTS.MAX_DESCRIPTION_LENGTH}个字符` }
  ],
  STATUS: [
    { required: true, message: '请选择活动状态' }
  ],
  DATE_RANGE: [
    { required: true, message: '请选择活动时间范围' }
  ],
  TARGET_DAYS: [
    { required: true, message: '请输入目标天数' },
    { type: 'number', min: 1, max: 365, message: '目标天数应在1-365天之间' }
  ],
  PARTICIPANTS: [
    { type: 'number', min: 0, max: DEFAULTS.MAX_PARTICIPANTS, message: `参与人数不能超过${DEFAULTS.MAX_PARTICIPANTS}人` }
  ],
};

// 日期格式
export const DATE_FORMATS = {
  DATE: 'YYYY-MM-DD',
  DATE_TIME: 'YYYY-MM-DD HH:mm:ss',
  TIME: 'HH:mm:ss',
  MONTH_DAY: 'MM-DD',
  YEAR_MONTH: 'YYYY-MM',
};

// 进度状态
export const PROGRESS_STATUS = {
  PENDING: 'pending',
  IN_PROGRESS: 'in_progress',
  COMPLETED: 'completed',
  OVERDUE: 'overdue',
};

// 获取进度状态
export const getProgressStatus = (progress, targetDays, completedDays) => {
  if (progress >= 100) return PROGRESS_STATUS.COMPLETED;
  if (completedDays > targetDays) return PROGRESS_STATUS.OVERDUE;
  if (completedDays > 0) return PROGRESS_STATUS.IN_PROGRESS;
  return PROGRESS_STATUS.PENDING;
};

// 获取进度颜色
export const getProgressColor = (progress, targetDays, completedDays) => {
  const status = getProgressStatus(progress, targetDays, completedDays);
  switch (status) {
    case PROGRESS_STATUS.COMPLETED:
      return '#52c41a';
    case PROGRESS_STATUS.OVERDUE:
      return '#ff4d4f';
    case PROGRESS_STATUS.IN_PROGRESS:
      return '#1890ff';
    default:
      return '#d9d9d9';
  }
}; 